#ifndef GODOT_STRING_HPP
#define GODOT_STRING_HPP

#include "Variant.hpp"

namespace Godot
{
class String:public godot_string
{

public:

//typedef godot_string&& (* godot_gdnative_core_api_struct::*w)(const godot_variant*);
//以下定义一个类成员指针，用于Variant的ValueOf
    constexpr static auto VariantAs=&godot_gdnative_core_api_struct::godot_variant_as_string;


    String()
    {
        Godot::GODOT_CORE_API->godot_string_new(this);
    }
    String(const String &p_v)
    {
        Godot::GODOT_CORE_API->godot_string_new_copy(this,&p_v);
    }
    String& operator=(const String& p_v)
    {
        GODOT_CORE_API->godot_string_destroy(this);//先将原本指向的数据清除
        GODOT_CORE_API->godot_string_new_copy(this,&p_v);//拷贝数据
        return *this;
    }
    String(String&& p_v)
    {
        *(POINTER_T*)_dont_touch_that=*(POINTER_T*)(p_v._dont_touch_that);
    }
    String& operator=(String&& p_v)
    {

        GODOT_CORE_API->godot_string_destroy(this);//先将原本指向的数据清除

        *(POINTER_T*)_dont_touch_that=*(POINTER_T*)(p_v._dont_touch_that);

        return *this;
    }



    String(const char *contents)
    {
        Godot::GODOT_CORE_API->godot_string_new(this);
        Godot::GODOT_CORE_API->godot_string_parse_utf8(this,contents);
    }
    String& operator=(const char *contents)
    {
        GODOT_CORE_API->godot_string_destroy(this);
        Godot::GODOT_CORE_API->godot_string_parse_utf8(this,contents);
        return *this;
    }

    ~String()
    {
        Godot::GODOT_CORE_API->godot_string_destroy(this);
    }

    String operator+(const String& p_v){
        return (String&&)Godot::GODOT_CORE_API->godot_string_operator_plus(this,&p_v);
    }


    inline void destroy();

    inline Variant toVariant();
    inline godot_char_string char_string();

};
void String::destroy()
{
    GODOT_CORE_API->godot_string_destroy(this);
}
Variant String::toVariant()
{
    godot_variant ret;
    GODOT_CORE_API->godot_variant_new_string(&ret,this);
    return (Variant&)ret;
}
godot_char_string String::char_string()
{
    return GODOT_CORE_API->godot_string_ascii(this);
}





}


#endif // GODOT_STRING_HPP
